﻿namespace Domain.UserManagement.Entities
{
    using System;
    using System.Web.Security;

    public class User
    {
#warning Comment by Elmar: There was no Key on this entity so it broke the database for us all.
        public int Id { get; set; }

        /// <summary>
        /// Gets or sets the name of the user.
        /// </summary>
        /// <value>
        /// The name of the user.
        /// </value>
        public string UserName { get; set; }
        /// <summary>
        /// Gets or sets the first name.
        /// </summary>
        /// <value>
        /// The first name.
        /// </value>
        public string FirstName { get; set; }
        /// <summary>
        /// Gets or sets the last name.
        /// </summary>
        /// <value>
        /// The last name.
        /// </value>
        public string LastName { get; set; }
        /// <summary>
        /// Gets or sets the company id.
        /// </summary>
        /// <value>
        /// The company id.
        /// </value>
        public string CompanyId { get; set; }
        /// <summary>
        /// Gets or sets the password.
        /// </summary>
        /// <value>
        /// The password.
        /// </value>
        public Password UserPassword { get; set; }
        /// <summary>
        /// Gets or sets the user role.
        /// </summary>
        /// <value>
        /// The user role.
        /// </value>
        public Role UserRole { get; set; }

        public User()
        {
            UserRole = new Role();
            UserPassword = new Password();
        }

        /// <summary>
        /// Changes the role.
        /// </summary>
        /// <param name="newRole">The new role.</param>
        //public void ChangeRole(Role newRole)
        //{
        //    throw new NotImplementedException();
        //}

        /// <summary>
        /// Changes the password.
        /// </summary>
        /// <param name="newPassword">The new password.</param>
        public bool ChangePassword(string newPassword)
        {
            if (UserPassword.ChangePassword(newPassword))
            {
                return true;
            }

            return false;
        }

    }
}
